//
//  HTNoDataView.m
//  TruckUser
//
//  Created by Ting Han on 2017/10/16.
//  Copyright © 2017年 Ting Han. All rights reserved.
//

#import "HTNoDataView.h"
#import "UIView+Layout.h"
@interface HTNoDataView()
@property (nonatomic,strong) UILabel * label;
@property (nonatomic,strong) UIImageView * imageView;
@end
@implementation HTNoDataView

- (instancetype) initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if(self) {
        [self setup];
    }
    return  self;
}

- (void)setShowMessage:(NSString *)showMessage{
    _showMessage = showMessage;
    self.label.text = showMessage;
}
- (void) setup
{
    self.backgroundColor = kBackgroundColor;
    [self addSubview:self.imageView];
    [self addSubview:self.label];
   
}


- (UIImageView *) imageView
{
    if(_imageView == nil) {
        CGFloat imgW = kWidth(100);
        CGFloat imgH = kWidth(100);
        _imageView  = [[UIImageView alloc] initWithFrame:CGRectMake(self.center.x-imgW*0.5,self.center.y-imgH - kWidth(50), imgW, imgH)];
        _imageView.centerX = self.centerX;
        _imageView.image = [UIImage imageNamed:@"default_diliver"];
        
    }
    
    return  _imageView;
}

- (UILabel *) label
{
    if(_label == nil) {
        _label = [[UILabel alloc] initWithFrame:CGRectMake(0, CGRectGetMaxY(self.imageView.frame)+kWidth(20), self.frame.size.width, 15)];
        _label.textAlignment = NSTextAlignmentCenter;
        _label.textColor = [UIColor lightGrayColor];
        _label.font = [UIFont systemFontOfSize:15];
    }
    return  _label;
}


@end
